

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>2 部署一个centos6+nginx+php的环境 &mdash; cookbook 3.0.0 documentation</title>
  

  
  
  
  

  

  
  
    

  

  <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="关于" href="../aboutme.html" />
    <link rel="prev" title="1 安装k8s 环境部分" href="k8s-1.html" /> 

  
  <script src="../_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="../index.html" class="icon icon-home"> cookbook
          

          
          </a>

          
            
            
              <div class="version">
                3.0
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="../chapters/k8s.html">k8s 部署nginx+php</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="k8s-1.html">1 安装k8s 环境部分</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">2 部署一个centos6+nginx+php的环境</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#centos6">一 下载centos6镜像</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id1">二 文件准备</a></li>
<li class="toctree-l3"><a class="reference internal" href="#php7-0-13-nginx1-10">三 安装php7.0.13 + nginx1.10</a></li>
<li class="toctree-l3"><a class="reference internal" href="#image">四 生成image</a></li>
<li class="toctree-l3"><a class="reference internal" href="#k8s-tuike-dev">六 k8s 使用镜像生成容器 并测试tuike-dev环境</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../aboutme.html">关于</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../index.html">cookbook</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../index.html">Docs</a> &raquo;</li>
        
          <li><a href="../chapters/k8s.html">k8s 部署nginx+php</a> &raquo;</li>
        
      <li>2 部署一个centos6+nginx+php的环境</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../_sources/k8s/k8s-2.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="centos6-nginx-php">
<h1>2 部署一个centos6+nginx+php的环境<a class="headerlink" href="#centos6-nginx-php" title="Permalink to this headline">¶</a></h1>
<div class="section" id="centos6">
<h2>一 下载centos6镜像<a class="headerlink" href="#centos6" title="Permalink to this headline">¶</a></h2>
<div class="code sh highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># 从官方仓库下载</span>
<span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">hub</span><span class="o">.</span><span class="n">docker</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">r</span><span class="o">/</span><span class="n">library</span><span class="o">/</span><span class="n">centos</span><span class="o">/</span><span class="n">tags</span><span class="o">/</span>
<span class="n">docker</span> <span class="n">pull</span> <span class="n">centos</span><span class="p">:</span><span class="mf">6.9</span>

<span class="c1"># 从本地仓库下载</span>
<span class="n">docker</span> <span class="n">pull</span> <span class="n">docker1</span><span class="o">.</span><span class="n">boqii</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">bq</span><span class="o">/</span><span class="n">centos</span><span class="p">:</span><span class="n">v6</span><span class="o">.</span><span class="mi">9</span>
</pre></div>
</div>
</div>
<div class="section" id="id1">
<h2>二 文件准备<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># 准备安装包</span>
<span class="n">php</span><span class="o">-</span><span class="mf">7.0</span><span class="o">.</span><span class="mf">13.</span><span class="n">tar</span><span class="o">.</span><span class="n">gz</span>
<span class="n">freetype</span><span class="o">-</span><span class="mf">2.4</span><span class="o">.</span><span class="mf">0.</span><span class="n">tar</span><span class="o">.</span><span class="n">gz</span>
<span class="n">nginx</span><span class="o">-</span><span class="mf">1.10</span><span class="o">.</span><span class="mf">3.</span><span class="n">tar</span><span class="o">.</span><span class="n">gz</span>
<span class="n">pcre</span><span class="o">-</span><span class="mf">8.39</span><span class="o">.</span><span class="n">tar</span><span class="o">.</span><span class="n">gz</span>
<span class="n">openssl</span><span class="o">-</span><span class="mf">1.1</span><span class="o">.</span><span class="mi">0</span><span class="n">c</span><span class="o">.</span><span class="n">tar</span><span class="o">.</span><span class="n">gz</span>
<span class="n">zlib</span><span class="o">-</span><span class="mf">1.2</span><span class="o">.</span><span class="mf">8.</span><span class="n">tar</span><span class="o">.</span><span class="n">gz</span>
</pre></div>
</div>
</div>
<div class="section" id="php7-0-13-nginx1-10">
<h2>三 安装php7.0.13 + nginx1.10<a class="headerlink" href="#php7-0-13-nginx1-10" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li><strong>Dockerfile编写</strong></li>
</ul>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>FROM docker1.boqii.com/bq/centos:v6.9
MAINTAINER zhangzw zhangzw@boqii.com

workdir /etc/yum.repos.d/
copy Centos-6.repo CentOS-Base.repo
run rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 \
 &amp;&amp; yum install -y epel-release \
 &amp;&amp; yum install -y gcc make cmake ncurses-devel gcc-c++ autoconf automake zlib-devel dos2unix nc lrzsz openssl-devel pcre-devel libxml2 libxml2-devel libcurl libcurl-devel libpng-devel bzip2-devel libjpeg libjpeg-turbo-devel libmcrypt-devel mhash-devel mysql-devel libtool-ltdl libtool-ltdl-devel git bzip2-devel git supervisor autoconf automake xz wget unzip\
 &amp;&amp; yum clean all

 ENV PHP_DIR /usr/local/php
 ENV NGINX_DIR /usr/local/nginx
 ENV WORK_DIR /usr/local/src
 ENV WORK_DIR_tar /usr/local/src/tar

 # 包括php-fpm 配置文件
 copy etc ${WORK_DIR}/etc
 # 包括 nginx php 和一些扩展
 copy tar ${WORK_DIR_tar}

 run groupadd -r www \
     &amp;&amp; useradd -M -s /sbin/nologin -r -g www www \
     &amp;&amp; cd ${WORK_DIR_tar} \
     &amp;&amp; ls *|xargs -i tar -xf {} \
     &amp;&amp; cd nginx-1.10.3 \
         &amp;&amp; ./configure  \
         --prefix=${NGINX_DIR} \
         --pid-path=/var/run/nginx.pid \
         --with-http_ssl_module \
         --with-http_stub_status_module \
         --with-pcre=${WORK_DIR_tar}/pcre-8.39 \
         --with-zlib=${WORK_DIR_tar}/zlib-1.2.8 \
         --with-openssl=${WORK_DIR_tar}/openssl-1.1.0c \
         --with-http_stub_status_module \
         &amp;&amp; make \
         &amp;&amp; make install


 run cd ${WORK_DIR_tar} \
     &amp;&amp; cd freetype-2.4.0 \
        &amp;&amp; ./configure --prefix=/usr/local/freetype \
        &amp;&amp; make \
        &amp;&amp; make install \
     &amp;&amp; cd ${WORK_DIR_tar} \
     &amp;&amp; cd php-7.0.13 \
     &amp;&amp; ./configure    --prefix=${PHP_DIR}   \
         --with-libxml-dir=/usr/   \
         --with-pdo-mysql=mysqlnd   \
         --with-zlib   \
         --with-libxml-dir   \
         --with-openssl   \
         --with-config-file-path=${PHP_DIR}/etc/   \
         --with-config-file-scan-dir=${PHP_DIR}/etc/conf.d   \
         --with-freetype-dir=/usr/local/freetype \
         --with-gd   \
         --with-jpeg-dir   \
         --with-png-dir \
         --with-gettext \
         --with-curl \
         --with-mcrypt \
         --enable-fpm \
         --enable-gd-native-ttf   \
         --enable-mysqlnd   \
         --enable-mbstring  \
         --enable-opcache \
         --enable-zip \
       &amp;&amp; make \
       &amp;&amp; make install


 run cd ${WORK_DIR_tar}/php-7.0.13 \
     &amp;&amp; cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm \
     &amp;&amp; cp ${PHP_DIR}/etc/php-fpm.conf.default ${PHP_DIR}/etc/php-fpm.conf \
     &amp;&amp; cp ${PHP_DIR}/etc/php-fpm.d/www.conf.default ${PHP_DIR}/etc/php-fpm.d/www.conf \
     &amp;&amp; cp php.ini-production ${PHP_DIR}/etc/php.ini \
     &amp;&amp; mkdir /webwww/ \
     &amp;&amp; curl -sS https://getcomposer.org/installer | ${PHP_DIR}/bin/php &amp;&amp; mv composer.phar /usr/bin/composer \
     &amp;&amp; cd ${WORK_DIR_tar} \
     &amp;&amp; wget http://linux.thai.net/pub/thailinux/software/libthai/libdatrie-0.2.9.tar.xz -O libdatrie-0.2.9.tar.xz \
     &amp;&amp; xz -dk libdatrie-0.2.9.tar.xz \
     &amp;&amp; tar xvf libdatrie-0.2.9.tar \
     &amp;&amp; cd libdatrie-0.2.9 \
         &amp;&amp; ./configure --prefix=/usr/local/libdatrie \
         &amp;&amp; make \
         &amp;&amp; make install \
     &amp;&amp; cd ${WORK_DIR_tar} \
     &amp;&amp; wget https://github.com/zzjin/php-ext-trie-filter/archive/php7.zip -O php7.zip \
     &amp;&amp; unzip php7.zip \
     &amp;&amp; cd php-ext-trie-filter-php7 \
     &amp;&amp; ${PHP_DIR}/bin/phpize \
         &amp;&amp; ./configure --with-php-config=${PHP_DIR}/bin/php-config --with-trie_filter=/usr/local/libdatrie \
         &amp;&amp; make \
         &amp;&amp; make install \
     &amp;&amp; echo &quot;extension=trie_filter.so&quot; &gt;&gt; ${PHP_DIR}/etc/php.ini \
     &amp;&amp; rm -rf ${WORK_DIR_tar}/* \
     &amp;&amp; yum remove -y wget git unzip xz cmake \
     &amp;&amp; mkdir /nginx_logs \
     &amp;&amp; chown -R nobody:nobody /nginx_logs \
     &amp;&amp; yum clean all

 copy nginx/html/*  /webwww/
 copy nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf
 copy supervisord-fpm.conf /etc/supervisord.conf
 copy start.sh /root/start.sh
 EXPOSE 80
 ENTRYPOINT [&quot;/bin/sh&quot;, &quot;/root/start.sh&quot;]
</pre></div>
</div>
</div>
<div class="section" id="image">
<h2>四 生成image<a class="headerlink" href="#image" title="Permalink to this headline">¶</a></h2>
<div class="code sh highlight-default notranslate"><div class="highlight"><pre><span></span>#当前目录的结构如下:

api
├── bq-nginx-php7.yml
├── Centos-6.repo
├── Dockerfile
├── Dockerfile.1
├── Dockerfile.2
├── Dockerfile.centos69-v1.0
├── etc
│   ├── php-fpm.conf
│   ├── php-fpm.d
│   │   └── www.conf
│   └── php.ini
├── nginx
│   ├── conf
│   │   └── nginx.conf
│   └── html
│       ├── index.html
│       └── index.php
├── start.sh
├── supervisord.conf
├── supervisord-fpm.conf
├── supervisord-nginx.conf
└── tar
    ├── freetype-2.4.0.tar.gz
    ├── nginx-1.10.3.tar.gz
    ├── openssl-1.1.0c.tar.gz
    ├── pcre-8.39.tar.gz
    ├── php-7.0.13.tar.gz
    └── zlib-1.2.8.tar.gz

# 由于测试机器慢,这里首先分成三次 生成了三个镜像
&gt; Dockerfile.centos69-v1.0 -&gt; docker1.boqii.com/bq/centos69:v1.0
docker build   --tag docker1.boqii.com/bq/centos69:v1.0 -f Dockerfile.centos69-v1.0 .

&gt; Dockerfile.1 -&gt; docker1.boqii.com/bq/centos69-nginx:v1.0
docker build   --tag docker1.boqii.com/bq/centos69-nginx:v1.0 -f Dockerfile.1 .

&gt; Dockerfile.2 -&gt; docker1.boqii.com/bq/centos69-nginx-php7:v1.0
docker build   --tag docker1.boqii.com/bq/centos69-nginx-php7:v1.0 -f Dockerfile.2 .


# 一次生成v1.1镜像
docker build  --tag docker1.boqii.com/bq/centos69-nginx-php7:v1.1 .

&gt; 这里注意 fpm和nginx 配置中某些logs的目录可能不存在,请修改或创建

# 提交改镜像到 本地仓库
docker push docker1.boqii.com/bq/centos69-nginx-php7:v1.1

docker push docker1.boqii.com/bq/centos69-nginx-php7:v1.0
docker push docker1.boqii.com/bq/centos69-nginx:v1.0
docker push docker1.boqii.com/bq/centos69:v1.0
</pre></div>
</div>
<div class="figure">
<img alt="" src="https://img.zhangzw.club/assets/markdown-img-paste-20180605180317149.png" />
</div>
</div>
<div class="section" id="k8s-tuike-dev">
<h2>六 k8s 使用镜像生成容器 并测试tuike-dev环境<a class="headerlink" href="#k8s-tuike-dev" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li><strong>bq-nginx-php7.yml 文件</strong></li>
</ul>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cat</span> <span class="n">bq</span><span class="o">-</span><span class="n">nginx</span><span class="o">-</span><span class="n">php7</span><span class="o">-</span><span class="n">tuike</span><span class="o">-</span><span class="n">dev</span><span class="o">.</span><span class="n">yml</span>
<span class="n">apiVersion</span><span class="p">:</span> <span class="n">extensions</span><span class="o">/</span><span class="n">v1beta1</span>
<span class="n">kind</span><span class="p">:</span> <span class="n">Deployment</span>
<span class="n">metadata</span><span class="p">:</span>
  <span class="n">name</span><span class="p">:</span> <span class="n">bq</span><span class="o">-</span><span class="n">nginx</span><span class="o">-</span><span class="n">php7</span>
  <span class="n">labels</span><span class="p">:</span>
    <span class="n">k8s</span><span class="o">-</span><span class="n">php</span><span class="p">:</span> <span class="n">bq</span><span class="o">-</span><span class="n">nginx</span><span class="o">-</span><span class="n">php7</span>
  <span class="n">namespace</span><span class="p">:</span> <span class="n">web</span>
<span class="n">spec</span><span class="p">:</span>
  <span class="n">replicas</span><span class="p">:</span> <span class="mi">2</span>
  <span class="n">template</span><span class="p">:</span>
    <span class="n">metadata</span><span class="p">:</span>
      <span class="n">labels</span><span class="p">:</span>
        <span class="n">k8s</span><span class="o">-</span><span class="n">php</span><span class="p">:</span> <span class="n">bq</span><span class="o">-</span><span class="n">nginx</span><span class="o">-</span><span class="n">php7</span>
    <span class="n">spec</span><span class="p">:</span>
      <span class="n">containers</span><span class="p">:</span>
      <span class="o">-</span> <span class="n">image</span><span class="p">:</span> <span class="n">docker1</span><span class="o">.</span><span class="n">boqii</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">bq</span><span class="o">/</span><span class="n">centos69</span><span class="o">-</span><span class="n">nginx</span><span class="o">-</span><span class="n">php7</span><span class="p">:</span><span class="n">v1</span><span class="o">.</span><span class="mi">0</span>
        <span class="n">imagePullPolicy</span><span class="p">:</span> <span class="n">Always</span>
        <span class="n">name</span><span class="p">:</span> <span class="n">nginx</span><span class="o">-</span><span class="n">php7</span>
        <span class="n">ports</span><span class="p">:</span>
        <span class="o">-</span> <span class="n">containerPort</span><span class="p">:</span> <span class="mi">80</span>
        <span class="n">resources</span><span class="p">:</span>
          <span class="n">requests</span><span class="p">:</span>
            <span class="n">memory</span><span class="p">:</span> <span class="s2">&quot;50Mi&quot;</span>
            <span class="n">cpu</span><span class="p">:</span> <span class="s2">&quot;50m&quot;</span>
          <span class="n">limits</span><span class="p">:</span>
            <span class="n">memory</span><span class="p">:</span> <span class="s2">&quot;100Mi&quot;</span>
            <span class="n">cpu</span><span class="p">:</span> <span class="s2">&quot;100m&quot;</span>
        <span class="n">volumeMounts</span><span class="p">:</span>
        <span class="o">-</span> <span class="n">mountPath</span><span class="p">:</span> <span class="o">/</span><span class="n">webwww</span><span class="o">/</span>
          <span class="n">name</span><span class="p">:</span> <span class="n">nginx</span><span class="o">-</span><span class="n">www</span>
        <span class="o">-</span> <span class="n">mountPath</span><span class="p">:</span> <span class="o">/</span><span class="n">usr</span><span class="o">/</span><span class="n">local</span><span class="o">/</span><span class="n">nginx</span><span class="o">/</span><span class="n">conf</span><span class="o">/</span><span class="n">nginx</span><span class="o">.</span><span class="n">conf</span>
          <span class="n">name</span><span class="p">:</span> <span class="n">nginx</span><span class="o">-</span><span class="n">conf</span>
        <span class="o">-</span> <span class="n">mountPath</span><span class="p">:</span> <span class="o">/</span><span class="n">usr</span><span class="o">/</span><span class="n">local</span><span class="o">/</span><span class="n">php</span><span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">php</span><span class="o">.</span><span class="n">ini</span>
          <span class="n">name</span><span class="p">:</span> <span class="n">php</span><span class="o">-</span><span class="n">conf</span>
        <span class="o">-</span> <span class="n">mountPath</span><span class="p">:</span> <span class="o">/</span><span class="n">nginx_logs</span><span class="o">/</span>
          <span class="n">name</span><span class="p">:</span> <span class="n">log</span><span class="o">-</span><span class="n">conf</span>
      <span class="n">volumes</span><span class="p">:</span>
        <span class="o">-</span> <span class="n">name</span><span class="p">:</span> <span class="n">nginx</span><span class="o">-</span><span class="n">www</span>
          <span class="n">hostPath</span><span class="p">:</span>
            <span class="n">path</span><span class="p">:</span> <span class="o">/</span><span class="n">webwww</span><span class="o">/</span><span class="n">tuike</span><span class="o">-</span><span class="n">dev</span><span class="o">/</span>
        <span class="o">-</span> <span class="n">name</span><span class="p">:</span> <span class="n">nginx</span><span class="o">-</span><span class="n">conf</span>
          <span class="n">hostPath</span><span class="p">:</span>
            <span class="n">path</span><span class="p">:</span> <span class="o">/</span><span class="n">data</span><span class="o">/</span><span class="n">docker</span><span class="o">-</span><span class="n">ce</span><span class="o">-</span><span class="n">data</span><span class="o">/</span><span class="n">api</span><span class="o">/</span><span class="n">nginx</span><span class="o">/</span><span class="n">conf</span><span class="o">/</span><span class="n">nginx</span><span class="o">.</span><span class="n">conf</span>
        <span class="o">-</span> <span class="n">name</span><span class="p">:</span> <span class="n">php</span><span class="o">-</span><span class="n">conf</span>
          <span class="n">hostPath</span><span class="p">:</span>
            <span class="n">path</span><span class="p">:</span> <span class="o">/</span><span class="n">data</span><span class="o">/</span><span class="n">docker</span><span class="o">-</span><span class="n">ce</span><span class="o">-</span><span class="n">data</span><span class="o">/</span><span class="n">api</span><span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">php</span><span class="o">.</span><span class="n">ini</span>
        <span class="o">-</span> <span class="n">name</span><span class="p">:</span> <span class="n">log</span><span class="o">-</span><span class="n">conf</span>
          <span class="n">hostPath</span><span class="p">:</span>
            <span class="n">path</span><span class="p">:</span> <span class="o">/</span><span class="n">nginx_logs</span><span class="o">/</span><span class="n">k8s</span><span class="o">-</span><span class="n">tuike</span><span class="o">-</span><span class="n">dev</span><span class="o">/</span>
<span class="o">---</span>
<span class="n">apiVersion</span><span class="p">:</span> <span class="n">v1</span>
<span class="n">kind</span><span class="p">:</span> <span class="n">Service</span>
<span class="n">metadata</span><span class="p">:</span>
  <span class="n">name</span><span class="p">:</span> <span class="n">bq</span><span class="o">-</span><span class="n">nginx</span><span class="o">-</span><span class="n">php7</span><span class="o">-</span><span class="n">service</span>
  <span class="n">namespace</span><span class="p">:</span> <span class="n">web</span>
<span class="n">spec</span><span class="p">:</span>
  <span class="nb">type</span><span class="p">:</span> <span class="n">NodePort</span>
  <span class="n">ports</span><span class="p">:</span>
    <span class="o">-</span> <span class="n">port</span><span class="p">:</span> <span class="mi">80</span>
      <span class="n">nodePort</span><span class="p">:</span> <span class="mi">30080</span>
      <span class="n">protocol</span><span class="p">:</span> <span class="n">TCP</span>
  <span class="n">selector</span><span class="p">:</span>
    <span class="n">k8s</span><span class="o">-</span><span class="n">php</span><span class="p">:</span> <span class="n">bq</span><span class="o">-</span><span class="n">nginx</span><span class="o">-</span><span class="n">php7</span>
</pre></div>
</div>
<ul class="simple">
<li>根据yml文件部署</li>
</ul>
<div class="code sh highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># 创建</span>
<span class="n">kubectl</span> <span class="n">create</span> <span class="o">-</span><span class="n">f</span> <span class="n">bq</span><span class="o">-</span><span class="n">nginx</span><span class="o">-</span><span class="n">php7</span><span class="o">-</span><span class="n">tuike</span><span class="o">-</span><span class="n">dev</span><span class="o">.</span><span class="n">yml</span>

<span class="c1"># 修改配置重启</span>
<span class="n">kubectl</span> <span class="n">replace</span> <span class="o">-</span><span class="n">f</span> <span class="n">bq</span><span class="o">-</span><span class="n">nginx</span><span class="o">-</span><span class="n">php7</span><span class="o">-</span><span class="n">tuike</span><span class="o">-</span><span class="n">dev</span><span class="o">.</span><span class="n">yml</span>


<span class="c1"># 查看pods和service</span>
<span class="c1"># 确保 /webwww 目录下有测试文件,每台node节点都需要确认,或查看pod落在哪个节点上</span>
<span class="n">kubectl</span> <span class="n">get</span> <span class="n">pods</span><span class="p">,</span><span class="n">svc</span> <span class="o">-</span><span class="n">n</span> <span class="n">web</span> <span class="o">-</span><span class="n">o</span> <span class="n">wide</span>

<span class="c1"># 打开地址测试</span>
<span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="mf">172.16</span><span class="o">.</span><span class="mf">54.167</span><span class="p">:</span><span class="mi">30080</span><span class="o">/</span>
<span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="n">k8s</span><span class="o">-</span><span class="n">tuike</span><span class="o">-</span><span class="n">dev</span><span class="o">.</span><span class="n">boqii</span><span class="o">.</span><span class="n">com</span><span class="p">:</span><span class="mi">30080</span><span class="o">/</span>

<span class="c1"># 容器对应docker主机的目录挂载关系:</span>
<span class="c1"># k8s-tuike-dev的代码目录:   /webwww/tuike-dev</span>
<span class="c1"># k8s-tuike-dev的日志目录:   /nginx_logs/k8s-tuike-dev</span>
<span class="c1"># k8s-tuike-dev的nginx配置: /data/docker-ce-data/api/nginx/conf/nginx.conf</span>
<span class="c1"># k8s-tuike-dev的ini配置:   /data/docker-ce-data/api/etc/php.ini</span>
</pre></div>
</div>
<ul class="simple">
<li><strong>kubectl 查看web pods services</strong></li>
</ul>
<div class="figure">
<img alt="" src="https://img.zhangzw.club/assets/markdown-img-paste-20180606171026520.png" />
</div>
<ul class="simple">
<li><strong>kubectl 查看所有 pods services</strong></li>
</ul>
<div class="figure">
<img alt="" src="https://img.zhangzw.club/assets/markdown-img-paste-20180606171200560.png" />
</div>
<ul class="simple">
<li><strong>本地/webwww/tuike-dev 目录的文件</strong></li>
</ul>
<div class="figure">
<img alt="" src="https://img.zhangzw.club/assets/markdown-img-paste-20180606171256751.png" />
</div>
<ul class="simple">
<li><strong>浏览器打开的网址</strong></li>
</ul>
<div class="figure">
<img alt="" src="https://img.zhangzw.club/assets/markdown-img-paste-20180606171326981.png" />
</div>
<ul class="simple">
<li>** curl查看header头 **</li>
</ul>
<div class="figure">
<img alt="" src="https://img.zhangzw.club/assets/markdown-img-paste-20180606171352959.png" />
</div>
<ul class="simple">
<li><strong>k8s dashboard 显示的部署</strong></li>
</ul>
<div class="figure">
<img alt="" src="https://img.zhangzw.club/assets/markdown-img-paste-20180606171508218.png" />
</div>
<ul class="simple">
<li><strong>k8s dashboard 显示的服务</strong></li>
</ul>
<div class="figure">
<img alt="" src="https://img.zhangzw.club/assets/markdown-img-paste-20180606171532700.png" />
</div>
</div>
</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="../aboutme.html" class="btn btn-neutral float-right" title="关于" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="k8s-1.html" class="btn btn-neutral" title="1 安装k8s 环境部分" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2017, 熊能.

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    <script type="text/javascript">
        var DOCUMENTATION_OPTIONS = {
            URL_ROOT:'../',
            VERSION:'3.0.0',
            LANGUAGE:'None',
            COLLAPSE_INDEX:false,
            FILE_SUFFIX:'.html',
            HAS_SOURCE:  true,
            SOURCELINK_SUFFIX: '.txt'
        };
    </script>
      <script type="text/javascript" src="../_static/jquery.js"></script>
      <script type="text/javascript" src="../_static/underscore.js"></script>
      <script type="text/javascript" src="../_static/doctools.js"></script>

  

  <script type="text/javascript" src="../_static/js/theme.js"></script>

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>